<?php
/**
 * A simple description for this script
 *
 * PHP Version 5.2.0 or Upper version
 *
 * @package    Iris
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia>
 * @copyright  2010 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
 *
 */

abstract class Iris_Abstract_Block extends Iris_Abstract_Controller
{
	protected $blockName = null;
	protected $editMode  = false;
	protected $options   = array();

	public function __construct($blockName, $options = array(), $editMode = false)
	{
		$this->blockName = $blockName;
		$this->editMode  = $editMode;
		$this->options   = $options;
		$this->config =& Iris::$cms->getConfig();
		$this->output['config'] =& $this->config;
		$this->output['url']     = Iris::$url;
		$this->output['dirname'] = Iris::$dirname;
		$this->output['controller'] =& Iris::$_controller;
		$this->output['action']     =& Iris::$_action;
	}

	public function main()
	{
	}

	protected function _view()
	{
		if ( !$this->template )
		{
			$tplName = strtolower($this->blockName);

			if ( $this->editMode )
			{
				$tplName .= '.edit';
			}

			$this->template = Iris::$dirname.'.block.'.$tplName.'.tpl';
		}

		$this->_escapeHtml($this->output);
		$xoopsTpl = new xoopsTpl();
		$xoopsTpl->assign('iris', $this->output);
		$xoopsTpl->register_modifier('t', 'Iris::t');
		$xoopsTpl->register_modifier('raw', 'Iris_Class_Smarty::raw');
		$xoopsTpl->register_function('url', 'Iris_Class_Smarty::url');
		$xoopsTpl->register_modifier('currency', 'Iris_Class_Smarty::currency');
		$xoopsTpl->display('db:'.$this->template);
		unset($xoopsTpl);
	}
}

?>
